﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Security;
using System.Runtime.InteropServices;

namespace CommonExceptioin
{
    public static class ExceptionExtensions
    {
        /// <summary>
        /// 可以由系统处理的异常，不需要在进行时抛出的
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        public static bool IsFatal(this Exception ex)
        {
            return ex is CoreException
                || ex is StackOverflowException
                || ex is OutOfMemoryException
                || ex is AccessViolationException
                || ex is AppDomainUnloadedException
                || ex is ThreadAbortException
                || ex is SecurityException
                || ex is DivideByZeroException
                || ex is SEHException;
        }
    }
}
